<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ page import="org.apache.commons.httpclient.HttpClient"%>
<%@ page import="org.apache.commons.httpclient.methods.PostMethod"%>
<%@ page import="org.apache.commons.httpclient.HttpStatus"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'index.jsp' starting page</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
	</head>

	<body>
		<%
		String requestUrl = basePath + "check.at";
		HttpClient httpClient = new HttpClient();
		httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(60000);
		httpClient.getHttpConnectionManager().getParams().setSoTimeout(60000);
		PostMethod post = new PostMethod(requestUrl);
		String str = "<xml><ToUserName><![CDATA[sohu]]></ToUserName>    "
					+"<FromUserName><![CDATA[zhangsan]]></FromUserName>	"
					+"<CreateTime>123456789</CreateTime>               	"
					+"<MsgType><![CDATA[text]]></MsgType>             	"
					+"<Content><![CDATA[test]]></Content>	   			"
					+"<MsgId>1234567890123456</MsgId>					"
					+"</xml>                                           	";
		post.setRequestBody(str);
		int status = httpClient.executeMethod(post);
		if (status == HttpStatus.SC_OK) {
		%>
			OK
		<%
		} else {
		%>
			ERROR
		<%
			}
		%>
	</body>
</html>
